package cn.edu.nuaa.aadl2.generatorC.template

import org.osate.aadl2.Subcomponent
import org.osate.aadl2.ProcessSubcomponent
import org.osate.aadl2.ThreadSubcomponent
import org.osate.aadl2.SubprogramSubcomponent
import org.osate.aadl2.DataSubcomponent
import org.osate.aadl2.DeviceSubcomponent

import static extension cn.edu.nuaa.aadl2.generatorC.template.ProcessTemplate.*
import static extension cn.edu.nuaa.aadl2.generatorC.template.ThreadTemplate.*
import static extension cn.edu.nuaa.aadl2.generatorC.template.SubprogramTemplate.*
import static extension cn.edu.nuaa.aadl2.generatorC.template.DataTemplate.*
import static extension cn.edu.nuaa.aadl2.generatorC.template.SystemTemplate.*
import static extension cn.edu.nuaa.aadl2.generatorC.utils.StringUtils.*
import cn.edu.nuaa.aadl2.generatorC.utils.Tools
import org.osate.aadl2.SystemSubcomponent

class SubcomponentTemplate {

	def static template(Subcomponent subcomponent,String systemFolder) {
		switch subcomponent {
			ProcessSubcomponent: '''
				«subcomponent.create(systemFolder)»
				«Tools.addContent(systemFolder,Template.systemheadfile,"extern void process_"+subcomponent.name.convert+"();")»
			'''
			SubprogramSubcomponent: '''
				«subcomponent.create(systemFolder)»
			'''
			DataSubcomponent: '''
				«subcomponent.create(systemFolder)»
			'''
			SystemSubcomponent: ''' 
			 «println("SubcomponentTemplate -> SystemSubcomponent ")»
			«subcomponent.subsystemCreate(systemFolder)»
			'''
			default: '''«System.out.println("We have no concern about hardware... "+subcomponent.classifier.name+" - -")»'''
		}
	}

}
